//最新资讯
'use strict';
import React,{Component} from 'react';
import Util from '../common/util';
import styles from '../style/styles';
import Swiper from 'react-native-swiper';
import News from '../news/newsList';
import {
    View,
    Text,
    Image,
    TouchableOpacity,
} from 'react-native';
export default class homeHotNews extends Component {
    // 构造
    constructor(props) {
        super(props);
        // 初始状态
        this.state = {};
    }

    showNews() {
        let that = this;
        let dataindex = this.props.dataindex;
        let rows;
        let list = [];
        for (let i in dataindex) {
            rows = (
                <View key={i} style={styles.news_list}>
                    <Text numberOfLines={1} style={{fontSize:12,color:'#ccc'}}>{dataindex[i].title}</Text>
                </View>
            )
            list.push(rows)
        }
        return list;
    }

    newsMore() {
        this.props.navigator.push({
            component: News,
            passProps: {
                type: 2
            }
        })
    }

    render() {
        return (
            <View style={styles.hot_news}>
                <Image
                    resizeMode={'contain'}
                    style={styles.hot_img}
                    source={require('../imgs/headnews.jpg')}
                />
                <TouchableOpacity onPress={()=>this.newsMore()}>
                    <Swiper height={40} showsPagination={false} horizontal={false} autoplay={true}
                            style={styles.hot_new_wrap}>
                        {this.showNews()}
                    </Swiper>
                </TouchableOpacity>
            </View>
        )
    }
}